﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
public partial class Admin_login : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
  
    protected void LoginButton_Click1(object sender, EventArgs e)
    {

        Login login = (Login)LoginView1.FindControl("Login1");
        TextBox user = (TextBox)login.FindControl("username");
        TextBox pass = (TextBox)login.FindControl("password");

        DataView dv = new DataView();
        DataTable dt = new DataTable();

        dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
        dt = dv.ToTable();

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (dt.Rows[i]["StrUserName"].ToString() == user.Text && dt.Rows[i]["StrUserPass"].ToString() == pass.Text)
            {


                FormsAuthentication.RedirectFromLoginPage(dt.Rows[i]["StrUserName"].ToString(), true);

            }
            else
            {

                Response.Redirect("error.aspx");
            }

        }



    }
}
